/* GUI CONVERTED from rprsiq1a.p (converter v1.75) Tue Aug 22 11:49:22 2000 */
/* rprsiq1a.p - RESOURCE LOAD SUMMARY INQUIRY SUBROUTINE                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/* All rights reserved worldwide.  This is an unpublished work.        */
/* web convert rprsiq1a.p (converter v1.00) Fri Oct 10 13:58:00 1997 */
/* web tag in rprsiq1a.p (converter v1.00) Mon Oct 06 14:18:39 1997 */
/*F0PN*/ /*K17H*/ /*                                                    */
/*V8:ConvertMode=Report                                        */
/* REVISION: 1.0     LAST MODIFIED: 06/12/86    BY: pml                 */
/* REVISION: 1.0     LAST MODIFIED: 06/16/86    BY: emb                 */
/* REVISION: 2.0     LAST MODIFIED: 07/10/87    BY: emb *A76*           */
/* REVISION: 2.0     LAST MODIFIED: 01/06/88    BY: pml *A125*          */
/* REVISION: 4.0     LAST MODIFIED: 12/30/87    BY: wug *A137*          */
/* REVISION: 4.0     LAST MODIFIED: 03/23/88    BY: rl  *A171*          */
/* REVISION: 4.0     LAST MODIFIED: 06/20/89    BY: emb *A748*          */
/* REVISION: 5.0     LAST MODIFIED: 02/20/90    BY: wug *D017*          */
/* REVISION: 5.0     LAST MODIFIED: 04/04/90    BY: ram *B640*          */
/* REVISION: 6.0     LAST MODIFIED: 04/09/90    BY: ram *D018*          */
/* REVISION: 5.0     LAST MODIFIED: 09/27/90    BY: ram *B793*          */
/* REVISION: 6.0     LAST MODIFIED: 02/14/91    BY: ram *D351*          */
/* REVISION: 7.0     LAST MODIFIED: 10/11/91    BY: emb *F024*          */
/* REVISION: 7.3     LAST MODIFIED: 10/23/92    BY: ram *G231*          */
/* REVISION: 7.3     LAST MODIFIED: 11/20/92    BY: jcd *G345*          */
/* REVISION: 7.3     LAST MODIFIED: 10/17/95    BY: qzl *G0ZB*          */
/* REVISION: 8.6     LAST MODIFIED: 11/04/97    BY: bvm *K17H*          */
/* REVISION: 8.6     LAST MODIFIED: 12/13/97    BY: *H0QB*  Russ Witt   */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 09/08/98   BY: *J2Z1* G.Latha   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0K5* Arul Victoria   */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     {mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rprsiq1a_p_6 "Per Col"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsiq1a_p_10 "Qty Open"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 * &SCOPED-DEFINE rprsiq1a_p_1 "Load          "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq1a_p_2 "Past    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq1a_p_3 "Cumulative    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq1a_p_4 " LOAD % OF CAPACITY "
 * /* MaxLen: Comment: */
 *
 * /*J2Z1** &SCOPED-DEFINE rprsiq1a_p_5 "Press space bar to display graph" */
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq1a_p_7 "Over/Under    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq1a_p_8 "Capacity      "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq1a_p_9 "Workdays      "
 * /* MaxLen: Comment: */
 *
 *N0K5* ------------------- END   DELETE ----------------------- */

/*K17H*/ {wbrp02.i}

     define shared variable site like si_site.
     define shared variable start like rq_start.
     define shared variable ending like rq_end.
     define shared variable rscde like rq_rsc.
     define variable interval as integer extent 8.
     define variable sdate like ro_start extent 8.
/*H0QB*   define variable load as decimal extent 8 format "->>>,>>9"
                                                          initial 0.  */
/*H0QB*/  define new shared variable load as decimal extent 8 format "->>>,>>9"
/*H0QB*/                                                initial 0 no-undo.
/*H0QB*   define variable cap as decimal extent 8 format "->>>,>>9".  */
/*H0QB*/  define new shared variable cap as decimal extent 8 format "->>>,>>9"
/*H0QB*/                                                          no-undo.
     define variable ovund as decimal extent 8 format "->>>,>>9" initial 0.
     define variable cum as decimal extent 8 format "->>>,>>9".
     define variable workdays as integer extent 8 format ">>>>,>>9".
     define variable det_load as decimal extent 8 format "->>>,>>9"
        initial 0.
     define variable holiday as integer.
     define variable i as integer.
     define variable j as integer.
     define variable qty like rq_qty.
     define variable wostart as integer.
     define variable nonwdays as decimal.
     define variable elapsedays as integer.
     define variable wdays as integer.
     define variable overlap as integer.
     define variable wointerval as integer.
     define variable offset like rq_lt_off.
     define variable ltoff like rq_lt_off.
     define variable ltoffperiod as integer.
     define variable lead as integer.
/*H0QB* define shared variable dwm as character format "!(1)" label "D/W/M".*/
/*H0QB*/ define shared variable dwm as character format "!(1)" label "D/W/M/P".
     define shared variable idays as integer format ">>>>>9"
/*H0QB*   label "Per Column".  */
/*H0QB*/  label {&rprsiq1a_p_6}.
     define variable monthend as integer.
     define variable num_intervals as integer initial 7.
     define variable more like mfc_logical.
     define variable dev like prd_dev.
     define shared variable dev1 like prd_dev.
     define variable path like prd_path.
     define shared variable path1 like prd_path.

     define new shared variable vq_-ratio as integer extent 7 no-undo.
     define new shared variable vq_-title as character no-undo.
     define new shared variable vq_-period as date extent 14 no-undo.
     define new shared variable vq_-bar-color as character no-undo.
/*H0QB*/ define new shared variable vq_-day-week-month as character no-undo.
     define variable x as integer.

/*N0K5*/ define variable qty-open like wo_qty_ord no-undo.

     dev = dev1.
     path = path1.
     hide frame b.

         repeat:
        
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/
                                         /*G345*/

        /* COMPUTE START DATES */
        sdate[1] = today.
        {mfcsdate.i}

        do i = 1 to num_intervals + 1:
           sdate[i] = max(sdate[i],today).
           if i > 1 then interval[i - 1] = max(sdate[i] - sdate[i - 1],0).
        end.

        /* INITIALIZE VARIABLES */
        assign
           cap = 0
           workdays = 0
           load = 0
           ovund = 0
           cum = 0.

        /* CALCULATE WORKING DAYS IN EACH INTERVAL */
        {mfcwdays.i site}
        do i = 1 to num_intervals + 1:
           workdays[i] = max(workdays[i],0).
        end.

        /* CALCULATE CAPACITY IN EACH INTERVAL */
/*G231      {mfccap.i} */
/*G231*/    {mfccap.i site}

        {mfcsdate.i}
        {mfcwdays.i site}
        assign
           workdays[1] = max(workdays[1],0)
           sdate[1] = low_date.

        display space(15)
/*N0K5*    {&rprsiq1a_p_2}  */
/*N0K5*/         getTermLabel("PAST",8)
           sdate[2 for 6] skip
           space(15) sdate[2] - 1 sdate[3] - 1 sdate[4] - 1 sdate[5] - 1
             sdate[6] - 1 sdate[7] - 1 sdate[8] - 1 skip
           space(15)
           "-------- -------- -------- -------- -------- -------- --------"
/*N0K5*    {&rprsiq1a_p_9}   */
/*N0K5*/         getTermLabel("WORKDAYS",14) format "x(14)"
           workdays[1 for 7] skip
/*N0K5*    {&rprsiq1a_p_8}             */
/*N0K5*/    getTermLabel("CAPACITY",14) format "x(14)"
            cap[1 for 7] skip
        with frame b width 80 no-labels STREAM-IO /*GUI*/ .

        /* CALCULATE  LOAD IN EACH PERIOD  */
/*K17H*/   if c-application-mode <> 'web' then
              pause 0 no-message.
        if dev = "terminal" then do:
           {mfmsg.i 401 1}
        end.

        more = no.

        loopa:
        do:
           find shop_cal no-lock where shop_site = site
           and shop_wkctr = "" and shop_mch = "" no-error.
           if not available shop_cal then
           find shop_cal no-lock where shop_site = ""
           and shop_wkctr = "" and shop_mch = "" no-error.
           if available shop_cal then do:

          for each rq_mstr where rq_rsc = rscde
          and rq_site = site
          no-lock on endkey undo, leave loopa:

             
/*GUI*/ {mfguichk.i  &warn=no} /*Replace mfrpchk*/
                       /*G345*/

             for each wo_mstr where (wo_part = rq_part)
             and (wo_due_date >= rq_start or rq_start = ?)
             and (wo_due_date <= rq_end or rq_end = ?)
             and (wo_qty_ord - wo_qty_comp - wo_qty_rjct > 0)
             and (wo_status <> "C")
/*G0ZB*/             and wo_type <> "C"
             and wo_site = rq_site
             no-lock on endkey undo, leave loopa:

            
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/
                             /*G345*/

            /* CALCULATE LOAD FOR A GIVEN WORK ORDER */
            {mfcload.i}
            if ltoffperiod = num_intervals + 1 then more = yes.

            /* DISPLAY WORK ORDERS WHILE CALCULATING LOAD  */
/*K17H*/            if c-application-mode <> 'web' then
                       pause 0 no-message.
            if dev = "terminal" then do with frame c:
               /* SET EXTERNAL LABELS */
               setFrameLabels(frame c:handle).
               display wo_nbr wo_part
               wo_qty_ord - wo_qty_comp - wo_qty_rjct
/*N0K5*/       @ qty-open
                  label {&rprsiq1a_p_10}
               wo_due
               with frame c STREAM-IO /*GUI*/ .
            end.
             end.
          end.
           end.
        end.

        /* DISPLAY LOAD OVER/UNDER AND CUMULATIVE */
        hide frame c no-pause.

        display
/*N0K5*    {&rprsiq1a_p_1}    */
/*N0K5*/         getTermLabel("LOAD",14) format "x(14)"
           load[1 for 7] with frame b no-labels STREAM-IO /*GUI*/ .

        do i = 1 to num_intervals + 1:
           assign
          ovund[i] = integer(cap[i] - load[i])
          cum[i] = ovund[i].
           if i > 1 then cum[i] = cum[i] + cum[i - 1].
        end.
        display
/*N0K5*    {&rprsiq1a_p_7}  */
/*N0K5*/         getTermLabel("OVER/UNDER",14) format "x(14)"
           ovund[1 for 7] with frame b no-labels STREAM-IO /*GUI*/ .

        display
/*N0K5*    {&rprsiq1a_p_3}  */
/*N0K5*/         getTermLabel("CUMULATIVE",14) format "x(14)"
            cum[1 for 7] with frame b no-labels STREAM-IO /*GUI*/ .

/*K17H*/   if c-application-mode <> 'web' then
              pause 0 no-message.

        if path = "terminal"
/*K17H*/       and c-application-mode <> 'web'
        then repeat:

/*J2Z1*/   /* HARDCODED MESSAGE HAS BEEN REPLACED */
/*J2Z1**   message {&rprsiq1a_p_5}. */
/*J2Z1*/   {mfmsg.i 1143 1}
           readkey.
           if lastkey = 32 then do:

/*H0QB*/  vq_-day-week-month = dwm.
          do x = 1 to 7:
             assign
            vq_-period[x] = sdate[x]
            vq_-period[x + 7] = sdate[x + 1] - 1
/*H0QB*     vq_-ratio[x] = load[x] / cap[x] * 100.    */
/*H0QB*/    vq_-ratio[x] = truncate(load[x],0) / truncate(cap[x],0) * 100.
          end.

          /* ASSIGN THE COLORS */
          assign vq_-bar-color = if opsys eq "msdos"
                     and terminal eq "co80"
                     then "white/red"
                     else "message".

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *        /* ASSIGN THE TITLE */
 *        assign vq_-title = {&rprsiq1a_p_4}.
 *        /* NOTE LEADING/TRAILING BLANKS */
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
          /* ASSIGN THE TITLE */
          assign vq_-title =
              " " + caps(getTermLabel("LOAD_PERCENT_OF_CAPACITY",76)) +  " ".
/*N0K5* ------------------- END   ADD ----------------------- */

/*H0QB*/ /*V8+*/
/*H0QB*/      
                  {gprun.i ""gpgraphw.p""}      
           end.
           else leave.
        end.

        {mfsumtrl.i}
        status default.
     end.
/*K17H*/ {wbrp04.i}
